import numpy as np
import mindspore as ms
import mindspore.nn as nn
from mindspore import ops
from mindspore.common.initializer import initializer


class TestNet(nn.Cell):
    def __init__(self):
        super(TestNet, self).__init__()
        self.op = nn.Embedding(30, 30)

    def construct(self, x):
        out = self.op(x)
        return [out]


if __name__ == "__main__":
    net = TestNet()
    # weight_shape = encoder.fc.weight.shape
    # weight = initializer('ones', shape=weight_shape, dtype=ms.float32)
    # encoder.fc.weight = weight
    x = ms.Tensor(np.ones([3, 3]).astype(np.float32), ms.int32)
    result = net(x)
    print(result[0])
    print(result[0].mean())
    print(result[0].shape)
